<h2>Random six images</h2>

<?php 
	$conn = connectDB();
	
	// query DB
	$result = queryDB("SELECT id, filename, date_time, category, country FROM image ORDER BY RAND() LIMIT 6", $conn);
	
	$num = mysql_numrows($result);
	
	// Display records from the table
	echo "<table border='0' cellspacing='5' cellpadding='2'>";
	while ($row = mysql_fetch_array($result, MYSQL_NUM)) {
		echo    "<tr>
							<td width='250' rowspan='5' bgcolor='#333333' align='center'><a href=\"index.php?show=pic&id=$row[0]\" target=\"_self\"><img src='thumbnailer.php?src=$row[1]&x=250&y=187&f=0'/></a></td>
							<td>ID: $row[0]</td>
						</tr>
						<tr>
							<td>Filename: $row[1]</td>
						</tr>
						<tr>
							<td>Date time: $row[2]</td>
						</tr>
						<tr>
							<td>Category: $row[3]</td>
						</tr>
						<tr>
							<td>
							";
							if($row[4] != NULL) {
								echo "<img src='images/globe.gif' alt='This image has GPS coordinates'>";
							}
							
							echo "</td>
						</tr>
						<tr>
							<td colspan='2'><hr></td>
						</tr>";
	}
	echo "</table>";
	
	closeDB($conn);
?>